package com.googlecode.microanalyst.designer.model.property;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

public class StringPropertySource implements IPropertySource {

	private String value;
	private TextPropertyDescriptor descriptor;

	public StringPropertySource(String value, String id, String name) {
		this.value = value;
		descriptor = new TextPropertyDescriptor(id, name);
	}

	public Object getEditableValue() {
		return "" + value;
	}

	public IPropertyDescriptor[] getPropertyDescriptors() {
		return new IPropertyDescriptor[] { descriptor };
	}

	public Object getPropertyValue(Object propertyName) {
		return value;
	}

	public boolean isPropertySet(Object propertyName) {
		return value != null;
	}

	public void resetPropertyValue(Object propertyName) {
	}

	public void setPropertyValue(Object propertyName, Object value) {
		this.value = value + "";
	}

}
